#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> l(n), r(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	for (int i = 0; i < n; i++) cin >> r[i];
	vector<int> a;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans += max(l[i], r[i]);
		a.push_back(min(l[i], r[i]));
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < k - 1; i++) ans += a[i];
	cout << ans + 1 << endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _ = 1;
	cin >> _;
	while (_--)
	{
		solve();
	}
	return 0;
}